﻿using System;
using System.Collections.Generic;

namespace GameFrameWork
{
    [Serializable]
    /// <summary>
    /// 热更资源清单
    /// </summary>
    public class HotAssetsManifest
    {
        /// <summary>
        /// 资源版本
        /// </summary>
        public string Version;

        /// <summary>
        /// 键：AssetBundle的名字
        /// </summary>
        public List<HotBundleInfo> BundleArray;

        public HotAssetsManifest()
        {
            BundleArray = new List<HotBundleInfo>();
            Version = string.Empty;
        }

        /// <summary>
        /// 新增一个Bundle记录
        /// </summary>
        /// <param name="bundleName">bundle的Id</param>
        /// <param name="bundleInfo">bundle的对象</param>
        public void AddBundle(int crc, HotBundleInfo bundleInfo)
        {
            BundleArray.Add(bundleInfo);
        }

        /// <summary>
        /// 获取Bundle数据
        /// </summary>
        /// <param name="crc"></param>
        /// <returns></returns>
        public HotBundleInfo GetBundle(int crc)
        {
            HotBundleInfo bundleInfo = null;
            int count = BundleArray.GetCount();
            for (int index = 0; index < count; index++)
            {
                var ele = BundleArray.Get(index);
                if (ele.Crc32 == crc)
                {
                    bundleInfo = ele;
                    break;
                }
            }

            return bundleInfo;
        }
    }
}

